/**
 * H5网站设置
 *
 * @author zhangchengming
 */
define(["app", "jquery", "js/services/MessageBox",
    "js/services/MuseService"], function (app) {

    var deps = ["$scope", "$state", "$modal", "MessageBox", "MuseService"];

    function controller ($scope, $state, $modal, MessageBox, MuseService) {

        //获取信息
        $scope.getObjList = function () {

            MuseService.post("admin/muticonfig/getH5.json").success(
                function (data, status, headers, config) {
                    if (data.state == 0) {
                        $scope.mutiConfig = data.data;
                        if ($scope.mutiConfig == undefined) {
                            $scope.mutiConfig = {};
                            $scope.mutiConfig.addressUrl = "http://hyhz.ygsoft.com/ccai-mobile/index.html";
                            $scope.mutiConfig.isShowLogo = false;
                        }
                    } else {
                        MessageBox.notify(data.message);
                    }
                }
            );
        };

        $scope.getObjList();

        //保存
        $scope.saveObj = function () {
            MuseService.post("admin/muticonfig/saveOrUpdate.json", $scope.mutiConfig).success(
                function (data, status, headers, config) {
                    if (data.state == 0) {
                        MessageBox.notify("保存成功！");
                    } else {
                        MessageBox.error("保存异常:" + data.message);
                    }
                }
            );
        }

    }

    controller.$inject = deps;
    app.lazy.controller("MutiConfigH5EditController", controller);
});
